package org.windey.server.web;

import java.util.ArrayList;

public class AdminMenu {
	
	private ArrayList<MenuItem> menuitems;
	private String current;
	
	public AdminMenu(String current) {
		setMenuitems(new ArrayList<MenuItem>());
		setCurrent(current);
		MenuItem home = new MenuItem("index.jsp", "Home");
		MenuItem manage = new MenuItem("manageServer.jsp", "Manage Server");
		menuitems.add(home);menuitems.add(manage);
	}

	public void setMenuitems(ArrayList<MenuItem> menuitems) {
		this.menuitems = menuitems;
	}

	public ArrayList<MenuItem> getMenuitems() {
		return menuitems;
	}

	public void setCurrent(String current) {
		this.current = current;
	}

	public String getCurrent() {
		return current;
	}
	
	public String generate() {
		String s = "<div id=\"menu\">" + 
		"<ul>";
		for (MenuItem mi : menuitems) {
			if (mi.getLink().equalsIgnoreCase(getCurrent())) {
				s += "<li><a href=\"" + mi.getLink() + "\" class=\"active\">" + mi.getName() + "</a></li>";
			}
			else {
				s += "<li><a href=\"" + mi.getLink() + "\">" + mi.getName() + "</a></li>";
			}
		}
		s += "</ul></div>";
		return s;
	}
	

}
